package com.onepiece.shipelves.common.ticker;

/**
 * 基础交易对模型
 * symbol + currency
 * Created by guoyanjiang on 2019-03-28.
 */
public class BaseTickerPair {
    private String symbol;//币种简称
    private String currencyUnit;//计价方式


    public BaseTickerPair(String pair) {
        String[] info = null;
        if (pair.contains("_")) {
            info = pair.split("_");
        } else if (pair.contains("/")) {
            info = pair.split("/");
        } else {
            throw new RuntimeException("交易对格式有误");
        }
        symbol = info[0];
        currencyUnit = info[1];
    }

    public BaseTickerPair(String symbol, String currencyUnit) {
        this.symbol = symbol;
        this.currencyUnit = currencyUnit;
    }

    public String getSymbol() {
        return symbol;
    }

    public String getCurrencyUnit() {
        return currencyUnit;
    }

    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    public void setCurrencyUnit(String currencyUnit) {
        this.currencyUnit = currencyUnit;
    }

    public String providePairStr() {
        return String.format("%s_%s", symbol, currencyUnit);
    }
}
